<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="itheima" uri="http://itheima.com/common/"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() 
	                   + ":" + request.getServerPort() + path + "/";
%>
<%@page import="java.net.URLEncoder"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!-- 引入css样式文件 -->
	<!-- Bootstrap Core CSS -->
	<link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet" />
	<!-- MetisMenu CSS -->
	<link href="<%=basePath%>css/metisMenu.min.css" rel="stylesheet" />
	<!-- DataTables CSS -->
	<link href="$<%=basePath%>css/dataTables.bootstrap.css" rel="stylesheet" />
	<!-- Custom CSS -->
	<link href="<%=basePath%>css/sb-admin-2.css" rel="stylesheet" />
	<!-- Custom Fonts -->
	<link href="<%=basePath%>css/font-awesome.min.css" rel="stylesheet" type="text/css" />
	<link href="<%=basePath%>css/boot-crm.css" rel="stylesheet" type="text/css" />
<title>首页</title>
</head>
<body>
<div id="wrapper">
  <!-- 导航栏部分 -->
  <nav class="navbar navbar-default navbar-static-top" role="navigation"
		 style="margin-bottom: 0">
	<div class="navbar-header">
		<div class="navbar-brand" >论文管理系统</div> 
	</div>
	<!-- 导航栏右侧图标部分 -->
	<ul class="nav navbar-top-links navbar-right">
		<!-- 用户信息和退出 start -->
		<li class="dropdown">
			
			<ul >
				<li><a href="#"><i class="fa fa-user fa-fw"></i>
				               用户：${user.name}
				    </a>
				</li>
				<li>
					<a href="${pageContext.request.contextPath }/loginout">
					<i class="fa fa-sign-out fa-fw"></i>退出登录
					</a>
				</li>
			</ul> 
		</li>
		<!-- 用户信息和系统设置结束 -->
	</ul>
	<!-- 左侧显示列表部分 start-->
	<div class="navbar-default sidebar" role="navigation">
		<div class="sidebar-nav navbar-collapse">
			<ul class="nav" >
				<li>
				    <a href="${pageContext.request.contextPath }/student" class="active">
				      <i class="fa fa-edit fa-fw"></i> 学生管理
				    </a>
				</li>
				<li>
				    <a href="${pageContext.request.contextPath }/paper" class="active">
				      <i class="fa fa-dashboard fa-fw" ></i> 论文管理
				    </a>
				</li>
			</ul>
		</div>
	</div>
	<!-- 左侧显示列表部分 end--> 
  </nav>
    <!-- 客户列表查询部分  start-->
	<div id="page-wrapper">
		<div class="row">
			<div class="col-lg-12">
				<h1 class="page-header">论文信息管理</h1>
			</div>
			<!-- /.col-lg-12 -->
		</div>
		<!-- /.row -->
		<div class="panel panel-default">
			<div class="panel-body">
				<form class="form-inline" method="get" 
				      action="${pageContext.request.contextPath }/paperfindall">
					<div class="form-group">
						<label for="name">论文名称</label> 
						<input type="text" class="form-control" id="name" 
						                   value="${name}" name="name" />
					</div>
					
					<div class="form-group">
						<label for="name">作者</label> 
						<input type="text" class="form-control" id="studentname" 
						                   value="${studentname}" name="studentname" />
					</div>
				<div class="form-group">
						<label for="major">类型</label> 
						<input type="text" class="form-control" id="paperclass" 
						                   value="${paperclass}" name="paperclass" />
					</div>
					<button type="submit" class="btn btn-primary">查询</button>
				</form>
			</div>
		</div>
		<a href="#" class="btn btn-primary" data-toggle="modal" 
		           data-target="#newstudentDialog" onclick="clearstudent()">上传</a>
		<div class="row">
			<div class="col-lg-12">
				<div class="panel panel-default">
					<div class="panel-heading">论文信息列表</div>
					<!-- /.panel-heading -->
					<table class="table table-bordered table-striped">
						<thead>
							<tr>
								<th>论文编号</th>
								<th>论文题目</th>
								<th>作者</th>
								<th>作者ID</th>
								<th>类型</th>
								<th>评论</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${page.rows}" var="row">
								<tr>
									<td>${row.ID}</td>
									<td>${row.name}</td>
									<td>${row.studentname}</td>
									<td>${row.studentID}</td>
									<td>${row.paperclass}</td>
									<td>${row.say}</td>
									<td>
										<%-- <a href="#" class="btn btn-danger btn-xs" onclick="d(${row.ID})">下载</a> --%>
										<a href="${pageContext.request.contextPath }/download?ID=${row.ID}" class="btn btn-danger btn-xs">下载</a>
									</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
					<div class="col-md-12 text-right">
						<itheima:page url="${pageContext.request.contextPath }/paperfindall" />
					</div>
					<!-- /.panel-body -->
				</div>
				<!-- /.panel -->
			</div>
			<!-- /.col-lg-12 -->
		</div>
	</div>
	<!-- 客户列表查询部分  end-->
	
	
	
	
	<!-- 上传论文模态框 -->
<div class="modal fade" id="newstudentDialog" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
				<h4 class="modal-title" id="myModalLabel">上传论文</h4>
			</div>
			<%-- action="${pageContext.request.contextPath }/paperupload" method="post" --%>
			<div class="modal-body">
				<form class="form-horizontal" id="new_paper_form" enctype="multipart/form-data" action="${pageContext.request.contextPath }/paperupload" method="post"
								onsubmit="return r()">
					<div class="form-group">
						<label for="new_name" class="col-sm-2 control-label">
						    论文姓名
						</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="new_name" placeholder="论文姓名" name="name" />
						</div>
					</div>
					<div class="form-group">
						<label for="new_studentname" class="col-sm-2 control-label">
						    作者姓名
						</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="new_studentname" placeholder="作者姓名" name="studentname" />
						</div>
					</div>
					<div class="form-group">
						<label for="new_major" class="col-sm-2 control-label">
						   作者编号
						</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="new_studentID" placeholder="作者编号" name="studentID" />
						</div>
					</div>
					<div class="form-group">
						<label for="new_paperclass" class="col-sm-2 control-label">
						   论文类型
						</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="new_paperclass" placeholder="论文类型" name="paperclass" />
						</div>
					</div>
					
					<div class="form-group">
						<label for="new_paperclass" class="col-sm-2 control-label">
						   文件
						</label>
						<div class="col-sm-10">
							<input type="file" class="form-control" id="new_place" multiple="multiple"  name="upload" />
						</div>
					</div>		
			<div class="modal-footer">
			
				<button type="submit" class="btn btn-primary">上传论文</button>
			</div>	 	
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
			</div>
		</div>
	</div>
</div>
</div>
<!-- 引入js文件 -->
<!-- jQuery -->
<script src="${pageContext.request.contextPath }/js/jquery-1.11.3.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="${pageContext.request.contextPath }/js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="${pageContext.request.contextPath }/js/metisMenu.min.js"></script>
<!-- DataTables JavaScript -->
<script src="${pageContext.request.contextPath }/js/jquery.dataTables.min.js"></script>
<script src="${pageContext.request.contextPath }/js/dataTables.bootstrap.min.js"></script>
<!-- Custom Theme JavaScript -->
<script src="${pageContext.request.contextPath }/js/sb-admin-2.js"></script>
<!-- 编写js代码 -->
<script type="text/javascript">
//清空新建客户窗口中的数据
	function clearstudent() {
	    $("#new_name").val("");
	    $("#new_grade").val("")
	    $("#new_major").val("")
	    $("#new_contact").val("")
	    $("#new_papernum").val("");
	}
	// 通过id获取修改的客户信息
	function editstudent(ID) {
	    $.ajax({
	        type:"GET",
	        url:"<%=basePath%>studentfind",
	        data:{"ID":ID},
	        success:function(data) {
	            $("#edit_ID").val(data.ID);
	            $("#edit_name").val(data.name);
	            $("#edit_major").val(data.major);
	            $("#edit_grade").val(data.grade);
	            $("#edit_contact").val(data.contact);
	            $("#edit_papernum").val(data.papernum)
	        }
	    });
	    alert(data.name);
	}
	
	//下载
	
	function d(ID) {
			$.post("${pageContext.request.contextPath }/download",{"ID":ID});
	}
	
	
	function r(){
				alert("论文上传成功成功！");
				window.location.reload();
	}
</script>
</body>
</html>